package com.atguigu;

import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;

@WebServlet("/servletA")
public class servletA extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String username = req.getParameter("username");
        String password = req.getParameter("password");
      /*  System.out.println("用户名：" + username + "，密码：" + password);*/

        req.setAttribute("username", username);
        req.setAttribute("password", password);
        req.getRequestDispatcher("servletB").forward(req, resp);













     /*   String money = req.getParameter("money");
        System.out.println("A"+money);
        System.out.println("servletA被访问了");
        req.getRequestDispatcher("/servletB").forward(req,resp);*/

      /*  //向请求域存放对象
        req.setAttribute("request","requestMessage");
        //向会话域存放数据
        HttpSession session = req.getSession();
        session.setAttribute("session","sessionMessage");
        //向应用域存放数据
        ServletContext application = getServletContext();
        application.setAttribute("application","applicationMessage");


        Object requestMessage = req.getAttribute("request");
        System.out.println("请求域："+requestMessage);*/

        /* req.getRequestDispatcher("servletB").forward(req,resp);*/

    }
}
